<script setup lang="ts">
import {defineProps, ref, onMounted} from 'vue'

onMounted(() => {
  if (paramsRef.value.data.requestTransferNum !== undefined && paramsRef.value.data.requestTransferNum !== null) {
    if (paramsRef.value.data.pieceWeight !== undefined && paramsRef.value.data.pieceWeight !== null && paramsRef.value.data.pieceWeight !== 0) {
      paramsRef.value.data.requestTransferWeight = parseInt(paramsRef.value.data.requestTransferNum) * parseInt(paramsRef.value.data.pieceWeight);
    } else {
      paramsRef.value.data.requestTransferWeight = 0;
    }
    // 刷新单元格
    paramsRef.value.api.refreshCells();
  }
})
const props = withDefaults(
    defineProps<{
      params: any,
    }>(),
    {
      params: {},
    }
)
const value = ref(props.params.data.requestTransferNum || '')
// 使用 ref 创建可扩展的响应式对象
const paramsRef = ref(props.params);
const handleIptChange = (data: any) => {
  paramsRef.value.data.requestTransferNum = data
  if (paramsRef.value.data.pieceWeight == 0) {
    paramsRef.value.data.requestTransferWeight = 0;
    return;
  }
  paramsRef.value.data.requestTransferWeight = parseInt(data) * parseInt(paramsRef.value.data.pieceWeight);
  // 刷新单元格
  paramsRef.value.api.refreshCells();
}
</script>

<template>
  <div>
    <el-input-number v-model="value" :min="0" @change="handleIptChange"/>
  </div>
</template>

<style scoped lang="less">

</style>